﻿using com.guojin.mj.net.message.login;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ThisMyClub : EventManager
{
    public Text name, clubname, clubid, grade, allnumber, nownumber, introduction,ClubJianJie;
    public InputField Changeinput, clubidInput,AdmainInput;
    public InputField ZhuanID, ZhuanMoney;
    public GameObject chuji, zhongji,HeadImage,Gaoji;//升级俱乐部时展示那个面板
    public Button UpClubOK;
    public string HeadString;
    private void Start()
    {
        DownloadHeadTexture(HeadImage.GetComponent<RawImage>(), HeadString);
        if (SaveDate.GetInstance().Join)
        {
            BindingSource[10].SetActive(true);
        }
        else
        {
            BindingSource[10].SetActive(false);
        }
    }
    public override void InformationSetting()
    {
        Open();
    }

    public void SetPage(OneClubInfo me,int type) {
        if (type!=0)
        {
            BindingSource[7].SetActive(false);//管理员隐藏解散俱乐部按钮
            //BindingSource[8].SetActive(false);//管理员隐藏带入申请按钮
        }
        clubname.text = me.ClubName;
        clubid.text = me.ClubId.ToString();
        allnumber.text = me.NumPeople.ToString();
        nownumber.text = me.NowPeople.ToString();
        if (me.NumPeople == 100)
        {
            grade.text = "初级";
        }
        else if (me.NumPeople == 300)
        {
            grade.text = "中级";
        }
        else if (me.NumPeople == 500)
        {
            grade.text = "高级";
        }
        else if (me.NumPeople == 1000)
        {
            grade.text = "最高级";
        }
        name.text = me.CreateName;
        introduction.text = me.Clubcontent;
        HeadString = me.Address;
    }
    void Chage() {
        BindingSource[0].SetActive(true);
        Changeinput.text = "";
    }
    void ChageOk() {
        if (Changeinput.text != "")
        {
            ClubJianJie.text= Changeinput.text;
          MessageManager.GetInstance().SendMsg789(int.Parse(clubid.text), Changeinput.text);
            Changeinput.text = "";
            BindingSource[0].SetActive(false);
        }
        else
        {
            TooL.WenXinTiSi("简介不能修改为空");
        }
    }
    void ChageRet() {
        BindingSource[0].SetActive(false);
    }
    void close() {
        Destroy(BindingSource[1].gameObject);
    }
    void ShowNumber() {
        MessageManager.GetInstance().SendMsg773(clubid.text);
    }
    void check()
    {
        MessageManager.GetInstance().SendMsg776(int.Parse(clubid.text));
        SaveDate.GetInstance().Join = false;
        GameObject temp = GameObject.Find("joinmyclubs");
        if (temp)
        {
            temp.SetActive(false);
        }
    }
    void ADDcheck()
    {
        BindingSource[3].SetActive(true);
    }
    void Zhuan()
    {
        BindingSource[4].SetActive(true);
        ZhuanID.text = "";
        ZhuanMoney.text = "";
    }
    void Join()
    {
        BindingSource[2].SetActive(true);
    }
    void history()
    {
        MessageManager.GetInstance().Send7131(1,clubid.text);//获取俱乐部战绩
    }
    void CreateRoom()
    {
        UIManager.ChangeUI(UIManager.PageState.CreateRoomPage, (GameObject obj) =>
        {
            obj.GetComponent<CreateRoomPage>().InformationSetting();
            CreateRoomController.GetInstance().CreateRoomType = "1";
            obj.GetComponent<CreateRoomPage>().ClubOrLianMengID = clubid.text;
        });

        DestroyImmediate(this.gameObject);
    }

    void JoinRet() {
        BindingSource[2].SetActive(false);
    }
    void SendJoinId()
    {
        if (clubidInput.text != null && clubidInput.text != "")
        {
            MessageManager.GetInstance().SendMsg784(int.Parse(clubidInput.text));
        }
        else
        {
            TooL.WenXinTiSi("您输入的格式有误，请检查后重新输入");
        }
    }
    void AdmianRet() {
        BindingSource[3].SetActive(false);
    }
    void AdmianOk()
    {
        if (AdmainInput.text!=null&& AdmainInput.text!="")
        {
            MessageManager.GetInstance().SendMsg779(int.Parse(AdmainInput.text), int.Parse(clubid.text));
            AdmainInput.text = "";
        }
        else
        {
            TooL.WenXinTiSi("您的输入不合法");
        }
    }
    void ZhuanRet()
    {
        BindingSource[4].SetActive(false);
    }
    void Up() {
        if (allnumber.text == "100")
        {
            BindingSource[5].SetActive(true);//升级俱乐部面板
        }
        else if ((allnumber.text == "300")) {
            BindingSource[5].SetActive(true);
            chuji.SetActive(false);
            zhongji.SetActive(true);
        }
        else if ((allnumber.text == "500"))
        {
            BindingSource[5].SetActive(true);
            chuji.SetActive(false);
            Gaoji.SetActive(true);
        }
        else
        {
            TooL.WenXinTiSi("您的俱乐部已经升到最高级了");
        }
    }
    void UpRet() {
        BindingSource[5].SetActive(false);
    }
    public void UpOk1() {
        MessageManager.GetInstance().SendMsg795(1, int.Parse(clubid.text));//直接挂载到button上面
    }
    public void UpOk2()
    {
        MessageManager.GetInstance().SendMsg795(2, int.Parse(clubid.text));//直接挂载到button上面
    }
    public void UpOk3()
    {
        MessageManager.GetInstance().SendMsg795(3, int.Parse(clubid.text));//直接挂载到button上面
    }
    void ZhuanOk()
    {
        if ( ZhuanID.text != ""&& ZhuanMoney.text != "")
        {
            MessageManager.GetInstance().SendMsg781(int.Parse(ZhuanID.text), int.Parse(ZhuanMoney.text));
        }
        else
        {
            TooL.WenXinTiSi("您的输入不合法");
        }
    }
    void jieshanClub() {
        BindingSource[6].SetActive(true);
    }
    void jieshanOk()
    {
        BindingSource[6].SetActive(false);
        MessageManager.GetInstance().SendMsg791(int.Parse(clubid.text));
    }
    void jieshanDes()
    {
        BindingSource[6].SetActive(false);
    }
    void Renews() {//续费
        MessageManager.GetInstance().Send7127(int.Parse(clubid.text));
    }   
}
